Skip to content

MDEV-39222: Error when inserting data from seq#4897

Merged
bsrikanth-mariadb merged 1 commit intobb-12.3-MDEV-38805-dev-sprint-work-2from
12.3-MDEV-39222-error-with-insert-into-from-seq
Apr 15, 2026
Merged

MDEV-39222: Error when inserting data from seq#4897
bsrikanth-mariadb merged 1 commit intobb-12.3-MDEV-38805-dev-sprint-work-2from
12.3-MDEV-39222-error-with-insert-into-from-seq

Conversation

@bsrikanth-mariadb
Copy link
Copy Markdown
Contributor

@bsrikanth-mariadb bsrikanth-mariadb commented Apr 3, 2026

MDEV-39222: After loading saved optimizer context, further queries cause errors

The problem can be seen as:
source /tmp/saved_optimizer_context.sql
INSERT ..(or any DML);
-- This causes "Failed to match the stats from replay context" warning-turned-error.

The cause is that saved_optimizer_context.sql ends with:
set @opt_context=...;
set optimizer_replay_context='opt_context';

Note that optimizer_replay_context remains set and will apply for any further query.

== SOLUTION ==
Make saved optimizer context have this as last statement:
set optimizer_replay_context=NULL;
If one desires to replay the context, it's still available in @opt_context.

@bsrikanth-mariadb bsrikanth-mariadb force-pushed the 12.3-MDEV-39222-error-with-insert-into-from-seq branch 2 times, most recently from 9692a89 to 79bc8c6 Compare April 6, 2026 04:33
@spetrunia
Copy link
Copy Markdown
Member

The fix is ok, but the commit comment needs improvement.
Please use something like:

MDEV-39222: After loading saved optimizer context, further queries cause errors

The problem can be seen as:
source /tmp/saved_optimizer_context.sql
INSERT ..(or any DML);
-- This causes "Failed to match the stats from replay context" warning-turned-error.

The cause is that saved_optimizer_context.sql ends with:
  set @opt_context=...;
  set optimizer_replay_context='opt_context';
  <query for which the context was captured>
Note that optimizer_replay_context remains set and will apply for any further query.

== SOLUTION ==
Make saved optimizer context have this as last statement:
  set optimizer_replay_context=NULL;
If one desires to replay the context, it's still available in @opt_context.

Ok to push after changing.

Copy link
Copy Markdown
Member

@spetrunia spetrunia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok to push after the above is addressed.

…use errors

The problem can be seen as:
source /tmp/saved_optimizer_context.sql
INSERT ..(or any DML);
-- This causes "Failed to match the stats from replay context" warning-turned-error.

The cause is that saved_optimizer_context.sql ends with:
  set @opt_context=...;
  set optimizer_replay_context='opt_context';
  <query for which the context was captured>
Note that optimizer_replay_context remains set and will apply for any further query.

== SOLUTION ==
Make saved optimizer context have this as last statement:
  set optimizer_replay_context=NULL;
If one desires to replay the context, it's still available in @opt_context.
@bsrikanth-mariadb bsrikanth-mariadb force-pushed the 12.3-MDEV-39222-error-with-insert-into-from-seq branch from 79bc8c6 to 51da7f3 Compare April 15, 2026 09:45
@bsrikanth-mariadb bsrikanth-mariadb merged commit 51da7f3 into bb-12.3-MDEV-38805-dev-sprint-work-2 Apr 15, 2026
11 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants